<template>
	<view class="page">
		<TInput label="手机号码" type="number" v-model="lostInfo.phone" />
		<TInput label="密码" type="password" v-model="lostInfo.password" />
		<TInput label="姓名" type="text" v-model="lostInfo.name" />
		<TInput label="性别" type="text" v-model="sex" />
		<TInput label="年龄" type="text" v-model="lostInfo.age" />
		<TInput label="出生地" type="text" v-model="lostInfo.birthplace" />
		<TInput label="家庭住址" type="text" v-model="lostInfo.home_address" />
		<TInput label="工作地址" type="text" v-model="lostInfo.work_address" />
		<TInput label="身份证号码" type="text" v-model="lostInfo.ID_number" />
		<TInput label="职务" type="text" v-model="lostInfo.position" />
		<TInput label="角色类型" type="text" placeholder="家属、志愿者、救援队员" v-model="role"/>
		<TInput label="教育水平" type="text" v-model="lostInfo.edu_bg" />
		<view class="btn" @click="send">确定</view>
	</view>
</template>

<script>
	import TInput from '../../../components/inputItem/input.vue'
	import {newUser} from '../../../network/login.js'
	import {
		appendPersonLost
	} from '../../../network/me.js'
	export default {
		components: {
			TInput
		},
		data() {
			return {
				lostInfo: {},
				img_path: '',
				sex: '',
				role: '',
				roleList: ['家属', '志愿者', '救援队员']
			};
		},
		methods: {

			tao() {
				console.log(this.lost)
			},

			async send() {
				this.lostInfo.sex = this.sex == "男" ? 1 : 0
				this.lostInfo.role = this.roleList.indexOf(this.role)
				const result  = await newUser({...this.lostInfo})
				console.log(result)
				if (!result.flag) return 
				this.$store.commit('setLogin', true)
				this.$store.commit('setUserInfo', {
					user_id: result.information.id,
					userName: result.information.name,
					url: result.information.url,
					phone: result.information.phone
				})
				uni.switchTab({
					url: '/pages/index/MsgList/MsgList'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #FFFFFF;

		.title {
			margin: 10px 10px 0;
			text-align: center;
			color: #999999;
		}

		.column {
			margin: 10px 10px;

			textarea {
				display: block;
				width: calc(100% - 10px);
				height: 70px;
				padding: 5px;
				margin-top: 10px;
				background: none;
				outline: none;
				border: 0.5px solid #dddddd;
				border-radius: 3px;
			}

			.choose {
				margin-top: 10px;
				display: flex;
				align-items: center;

				view {
					width: 80px;
					height: 80px;
					border: 1px solid #dddddd;
					border-radius: 3px;
					font-size: 50px;
					line-height: 80px;
					color: #999999;
					text-align: center;
				}

				image {
					margin-right: 20px;
					width: 80px;
					height: 80px;
				}
			}
		}

		.btn {
			width: 50%;
			margin: 30px auto;
			padding: 10px 0;
			background-color: $uni-btn-color;
			color: white;
			text-align: center;
			border-radius: 30px;
			cursor: pointer;

			&:active {
				background-color: #999999;
				color: #333333;
			}
		}
	}
</style>
